package fun.zerone.service.order.biz.order;

import fun.zerone.service.order.dao.order.OrderDao;
import fun.zerone.service.order.entity.order.Order;
import fun.zerone.service.user.biz.user.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * Created by XQL on 2021/4/15.
 */
@Service
@DubboService
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @DubboReference
    private UserService userService;

    @Override
    public String findByOrderNo(String orderNo) {
        Order order = orderDao.findByOrderNo(orderNo);
        String resp = "";
        if (Objects.nonNull(order)) {
            resp = resp.concat(order.toString());
            String userStr = userService.find(order.getUserId());
            return resp.concat(userStr);
        }
        return resp;
    }

}
